<?php

namespace App\Providers;

use App\Services\Bank\BankApiClient;
use App\Services\Bank\BankApiConfig;
use App\Services\Bank\BankApiService;
use Illuminate\Support\ServiceProvider;

class BankApiServiceProvider extends ServiceProvider
{
    /**
     * Register services.
     */
    public function register(): void
    {
        $this->app->singleton(BankApiConfig::class, function ($app) {
            return new BankApiConfig(
                config('bank.erp_sys_code', 'jth'),
                config('bank.cust_no', '300036675'),
                config('bank.options', [])
            );
        });

        $this->app->singleton(BankApiClient::class, function ($app) {
            return new BankApiClient($app->make(BankApiConfig::class));
        });

        $this->app->singleton(BankApiService::class, function ($app) {
            return new BankApiService($app->make(BankApiClient::class));
        });
    }

    /**
     * Bootstrap services.
     */
    public function boot(): void
    {
        $this->publishes([
            __DIR__ . '/../../config/bank.php' => config_path('bank.php'),
        ], 'bank-config');
    }
}